package com.dp.appi.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dp.appi.dao.ExpCodesetDao;
import com.dp.appi.dao.ExplorationDao;
import com.dp.appi.dao.PackageDao;
import com.dp.appi.exception.PackageRuntimeException;
import com.dp.appi.service.PackageService;
import com.dp.appi.util.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Map;
import java.util.zip.ZipFile;
import java.io.File;
import java.io.IOException;
import java.util.*;


/**
 * Created by Administrator on 2016/8/25.
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class PackageServiceImpl implements PackageService {
    @Autowired
    private PackageDao packageDao;
    @Autowired
    private ExpCodesetDao expCodesetDao;
    @Autowired
    private ExplorationDao explorationDao;

    private static String delete = "del";
    private static String add = "add";
    private static String update = "up";
    private Map<String, Long> exploration = new HashMap<>();

    @Value("${file_path}")
    private String file_path;

    @Override
    public Map<String, Object> projectInfo(Long stage_id) {
        return packageDao.projectInfo(stage_id);
    }

    /**
     * 项目数据打包
     *
     * @param rootPath
     * @param param
     */
    @Override
    public String projectPack(String rootPath, Map<String, String> param, Integer classify) throws IOException {
        return packageDao.projectPack(rootPath, param, classify);
    }

    /**********************************解包开始**************************************************/
    /**
     * 压缩包解压后解析
     *
     * @param path    压缩包根目录路径
     * @param stageId 阶段Id（可能为空）
     * @param id 上传者
     * @return
     */
    @Override
    public Long analysisPackage(String path, String stageId,String id) {
        //添加更新项目阶段
        String stageFileName = "ProjectStageBaseInfo_*.tio";
        Long stage_id;
//        JSONObject stageObj = parseFileToJSONObject(path, stageFileName);
        JSONArray stageArr = parseFileToJSONArray(path, stageFileName);
        JSONObject stageObj = null;
        if (stageArr != null && stageArr.size() > 0) {
            stageObj = stageArr.getJSONObject(0);
            saveStageInf(stageObj, path,id);
        }

        if (isLong(stageId)) {
            stage_id = Long.valueOf(stageId);
        } else {
            //        stageObj.put("creater",id); 会存在面对面快传的情况
            stage_id = stageObj.getLong("stage_id");
        }

        //添加更新点位设计信息
        String pointFileName = "ProjectExplorePointInfo_*.tio";
        JSONArray pointArr = parseFileToJSONArray(path, pointFileName);
        //根据创建时间来排序，初始化排序
//        sortPoint(pointArr);
        if (pointArr != null && pointArr.size() > 0) {
            for (int i = 0; i < pointArr.size(); i++) {
                JSONObject pointObj = pointArr.getJSONObject(i);
                pointObj.put("stage_id", stage_id);//将阶段中的id放入点位信息设置中,防止添加的时候阶段id为空
                savePointInfo(pointObj);
            }

            //处理点位之间关联和台区标志
            for (int i = 0; i < pointArr.size(); i++) {
                JSONObject pointObj = pointArr.getJSONObject(i);
//                pointObj.put("stage_id", stage_id);//将阶段中的id放入点位信息设置中,防止添加的时候阶段id为空
                this.updatePointInfo(pointObj);
            }
        }


        //两点间跨越物，通道属性
        String channelFileName = "ProjectExploreAcrossOnChannelList_*.tio";
        JSONArray pointChannelArr = parseFileToJSONArray(path, channelFileName);
        if (pointChannelArr != null && pointChannelArr.size() > 0) {
            for (int i = 0; i < pointChannelArr.size(); i++) {
                JSONArray channelArr = pointChannelArr.getJSONObject(i).getJSONArray("channelAList");
                for (int j = 0; j < channelArr.size(); j++) {
                    JSONObject channelObj = channelArr.getJSONObject(j);
                    saveChannelInfo(channelObj);
                }
            }
        }
        //环境
        String environmentlFileName = "ProjectExploreEnvInfo_*.tio";
        JSONArray arrenv = parseFileToJSONArray(path, environmentlFileName);
        if (arrenv != null && arrenv.size() > 0) {
            for (int i = 0; i < arrenv.size(); i++) {
                JSONObject environmentObj = arrenv.getJSONObject(i).getJSONObject("envInfo");
                saveEnvironment(environmentObj, path);
            }
        }
        //照片
        String photolFileName = "ProjectExplorePointInfoPhoto_*.tio";
        JSONArray arr = parseFileToJSONArray(path, photolFileName);
        if (arr != null && arr.size() > 0) {
            for (int i = 0; i < arr.size(); i++) {
                JSONObject objtemp = arr.getJSONObject(i);

                JSONObject photoArr1 = objtemp.getJSONObject("onePhoto");
                JSONArray array1 = photoArr1.getJSONArray("photoList");
                for (int h = 0; h < array1.size(); h++) {
                    savePhoto(array1.getJSONObject(h), path);
                }

                JSONObject photoArr2 = objtemp.getJSONObject("twoPhoto");
                JSONArray array2 = photoArr2.getJSONArray("photoList");
                for (int h = 0; h < array2.size(); h++) {
                    savePhoto(array2.getJSONObject(h), path);
                }

//                JSONObject photoArr3 = objtemp.getJSONObject("threePhoto");
//                JSONArray array3 = photoArr3.getJSONArray("photoList");
//                for (int h = 0; h < array3.size(); h++) {
//                    savePhoto(array3.getJSONObject(h), path);
//                }
            }
        }
        return stage_id;
    }

    /**
     * 根据创建时间来排序,防止先创建子类的情况
     *
     * @param jsonArray
     * @return
     */
    public void sortPoint(JSONArray jsonArray) {
        if (jsonArray != null && jsonArray.size() > 0) {
            for (int i = 0; i < jsonArray.size() - 1; i++) {
                Object obj1 = jsonArray.getJSONObject(i).get("create_time");
                if (StringUtil.isNotEmpty(obj1)) {
                    for (int j = i + 1; j < jsonArray.size(); j++) {
                        JSONObject temp;
                        Object obj2 = jsonArray.getJSONObject(j).get("create_time");
                        if (StringUtil.isNotEmpty(obj2)) {
                            if (Long.parseLong(String.valueOf(obj1)) > Long.parseLong(String.valueOf(obj2))) {
                                temp = jsonArray.getJSONObject(i);
                                jsonArray.set(i, jsonArray.getJSONObject(j));
                                jsonArray.set(j, temp);
                            }
                        }
                    }
                }
            }
        }
//        System.out.print(jsonArray);
    }

    @Override
    public void calculateConer(Long id) {
        packageDao.calculateConer(id);
    }

    @Override
    public List<Map<String, Object>> explorationList(Long stage_id, Integer exploration_type, Integer classify) {
        return packageDao.explorationList(stage_id, exploration_type, classify);
    }

    @Override
    public Map<String, Object> expPhotoList(Long exploration_id) {
        return packageDao.expPhotoList(exploration_id);
    }

    @Override
    public void up_explor_byBYQID(Long exploration_id, Long explor_id) {
        packageDao.up_explor_byBYQID(exploration_id, explor_id);
    }

    /**
     * 存储踏勘照片
     *
     * @param obj
     * @param path 文件目录
     */
    public void savePhoto(JSONObject obj, String path) {
        String flag = obj.getString("flag");
        //处理项目
//        Long photo_id = obj.getLong("environment_id");
        Long photo_id = obj.getLong("photo_id");
        if (StringUtil.isNotEmpty(flag)) {
            if (delete.equals(flag)) {
                deleteTableRowByKey(obj, "p_exploration_photo", photo_id, "photo_id", false);
            } else {
                Long exploration_id = getLongIdForUUidMap(obj, "exploration_id");
                //先转移图片到upload目路
                String photo_url = obj.getString("photo_url");
                if (StringUtil.isNotEmpty(photo_url)) {
                    List resultList = new ArrayList();
                    FileUtil.findFiles(path, photo_url, resultList);
                    if (resultList.size() > 0) {
                        File file = (File) resultList.get(0);
                        String photo_type = obj.getString("photo_type");
                        String tempPath = "";
                        if ("1".equals(photo_type)) {
                            tempPath = "stage_" + exploration_id + "/recon_first/";
                        } else if ("2".equals(photo_type)) {
                            tempPath = "stage_" + exploration_id + "/recon_second/";
                        } else if ("3".equals(photo_type)) {
                            tempPath = "stage_" + exploration_id + "/recon_third/";
                        }
                        String[] _files = photo_url.split("\\.");
                        String suffix = _files[1];
                        String filename = _files[0];
                        File fileDir = new File(file_path + tempPath);
                        if (!fileDir.exists()) {
                            fileDir.mkdirs();
                        }
                        FileUtil.fileRomoveTo(file, file_path + tempPath + photo_url);
                        String _paththumb = tempPath + filename + "_300x300" + "." + suffix;
                        String thumbPath = file_path + _paththumb;//缩略图路径
                        //开始切图
                        ImageUtils.scale2(file_path + tempPath + photo_url, thumbPath, 300, 300, true);
                        obj.put("photo_url", "upload/" + tempPath + photo_url);
                        obj.put("photo_thumb", "upload/" + _paththumb);
//                        obj.put("creat_time",new Date());


                        //这里需要注意返回数据
                        obj.put("exploration_id", getLongIdForUUidMap(obj, "exploration_id"));
                        photo_id = saveAndChangeTable(obj, "p_exploration_photo", photo_id, "photo_id", new String[]{"create_time"}, new String[]{"create_time"}, false);
                        obj.put("photo_id", photo_id);
                    }
                }
            }
        }
    }

    /**
     * 存储环境变量
     *
     * @param obj 参数对象
     */
    public void saveEnvironment(JSONObject obj, String path) {
        //存储通道信息
        //flag:add/up/del
        if (obj != null) {
            String flag = obj.getString("flag");
            //处理项目
            Long channel_id = obj.getLong("environment_id");
            if (StringUtil.isNotEmpty(flag)) {
                if (delete.equals(flag)) {
                    deleteTableRowByKey(obj, "p_environment", channel_id, "environment_id", false);
                } else {
                    //这里需要注意返回数据
                    obj.put("create_time", new Date());
                    //语音备注
                    String voice_remark = obj.getString("voice_remark");
                    if (StringUtil.isNotEmpty(voice_remark)) {
                        //语音移动到指定目录
                        List resultList = new ArrayList();
                        FileUtil.findFiles(path, voice_remark, resultList);
                        //更改语音文件
                        if (resultList.size() > 0) {
                            File file = (File) resultList.get(0);
                            String tempPath = "projectRadio/";
                            String[] _files = voice_remark.split("\\.");
                            String suffix = _files[1];
                            String filename = _files[0];
                            File fileDir = new File(file_path + tempPath);
                            if (!fileDir.exists()) {
                                fileDir.mkdirs();
                            }
                            FileUtil.fileRomoveTo(file, file_path + tempPath + voice_remark);
                            obj.put("voice_remark", "upload/" + tempPath + voice_remark);
                        }
                    }
                    obj.put("exploration_id", getLongIdForUUidMap(obj, "exploration_id"));
                    channel_id = saveAndChangeTable(obj, "p_environment", channel_id, "environment_id", new String[]{"create_time"}, new String[]{}, false);
                    obj.put("environment_id", channel_id);
                }
            }
        }
    }

    /**
     * 存储通道信息
     *
     * @param obj 通道信息
     */
    public void saveChannelInfo(JSONObject obj) {
        //存储通道信息
        //flag:add/up/del
        String flag = obj.getString("flag");
        //处理项目
        Long channel_id = obj.getLong("channel_id");
        if (StringUtil.isNotEmpty(flag)) {
            if (delete.equals(flag)) {
                deleteTableRowByKey(obj, "p_channel", channel_id, "channel_id", false);
            } else {
                //这里需要注意返回数据
                obj.put("create_time", new Date());
                Long a = getLongIdForUUidMap(obj, "exploration_id");
                if (a != null) {
                    obj.put("exploration_id", getLongIdForUUidMap(obj, "exploration_id"));//下级定位点
                    obj.put("feature_id", getLongIdForUUidMap(obj, "feature_id"));//特征点id
                    channel_id = saveAndChangeTable(obj, "p_channel", channel_id, "channel_id", new String[]{"create_time"}, new String[]{}, false);
                    obj.put("channel_id", channel_id);
                }
            }
        }
    }

    /**
     * 如果外键踏勘id是uuid那么切换成Long id
     *
     * @return
     */
    public Long getLongIdForUUidMap(JSONObject obj, String fieldName) {
        String uuidOrid = String.valueOf(obj.get(fieldName));
        if (!isLong(uuidOrid)) {//查找踏勘点id
            Long expid = exploration.get(uuidOrid);
            if (expid != null) {
                return expid;

            } else {
//                throw new PackageRuntimeException(SYS.PACK0005.name());
               return null;
            }
        } else {
            return Long.parseLong(uuidOrid);
        }
    }

    /**
     * 保存点位信息(p_exploration)根据点位类型加入不同的点位类型表
     *
     * @param obj
     */
    public void savePointInfo(JSONObject obj) {
        //存储点位信息
        JSONObject ptobj = obj.getJSONObject("pt");
        if (ptobj != null) {
            String pointTableName = packageDao.getPointTableName(obj.getLong("pt_id"));
            savePoint(ptobj, pointTableName);
            Object pt_objectid = ptobj.get("id");
            obj.put("pt_objectid", pt_objectid);
        }
        //flag:add/up/del
        String flag = obj.getString("flag");
        //处理项目
        Long exploration_id = obj.getLong("exploration_id");
        if (StringUtil.isNotEmpty(flag)) {
            if (delete.equals(flag)) {
                deleteTableRowByKey(obj, "p_exploration", exploration_id, "exploration_id", false);
            } else {
//                if (obj.get("before_exp") != null) {
//                    obj.put("before_exp", getLongIdForUUidMap(obj, "before_exp"));//上一级id
//                    Long temp = explorationDao.getExplorIdByBeforeExp(obj.getLong("before_exp"), new ArrayList<Long>());
//                    if (temp != null) {
//                        obj.put("explor_id", temp);//所属台区
//                    } else {
//                        obj.remove("explor_id");
//                    }
//                }
//                obj.remove("explor_id");
//                obj.remove("before_exp");
                obj.put("create_time", new Date());
                exploration_id = saveAndChangeTable(obj, "p_exploration", exploration_id, "exploration_id",
                        new String[]{"create_time", "explor_id", "before_exp"}, new String[]{"create_time", "explor_id", "before_exp"}, false);
                if (StringUtil.isNotEmpty(obj.get("uuid"))) {
                    exploration.put(String.valueOf(obj.get("uuid")), exploration_id);
                }
                obj.put("exploration_id", exploration_id);
                //如果典设方案不为空 统计
                Long codeset_id = obj.getLong("codeset_id");
                if (codeset_id != null) {
                    expCodesetDao.saveExpCodeset(codeset_id, exploration_id);
                    expCodesetDao.updateExpCodeset(exploration_id);
                }
            }

        }
    }

    /**
     * 更新插入数据库中的点位数据上联关系和台区标志
     *
     * @param obj
     */
    public void updatePointInfo(JSONObject obj) {
        String flag = obj.getString("flag");
        String pt_id = obj.getString("pt_id");
        String uuid = obj.getString("uuid");
        String before_exp = obj.getString("before_exp");
        Long exploration_id;
        if (uuid != null && !uuid.equals("")) {
            exploration_id = getLongIdForUUidMap(obj, "uuid");
        } else {
            exploration_id = obj.getLong("exploration_id");
        }
        JSONObject obj2 = new JSONObject();


        if (!flag.equals("del")) {
            if (before_exp != null && !before_exp.equals("")) {
                obj2.put("before_exp", getLongIdForUUidMap(obj, "before_exp"));//上一级id
//                     obj2.put("exploration_id",exploration_id );//当前点位id

//                packageDao.updateTableByParam( "p_exploration", new String[]{}, obj2,exploration_id);


//                    Long temp = explorationDao.getExplorIdByBeforeExp(obj.getLong("before_exp"), new ArrayList<Long>());
//                    if (temp != null) {
//                        obj.put("explor_id", temp);//所属台区
//                    } else {
//                        obj.remove("explor_id");
//                    }
                if (pt_id.equals("100002")) {
                    obj2.put("explor_id", exploration_id);//台区设置
                }
                saveAndChangeTable(obj2, "p_exploration", exploration_id, "exploration_id",
                        new String[]{"create_time"}, new String[]{""}, false);
            }


        }
    }

    /**
     * 根据点位类型存储对象的点位表
     *
     * @param obj       点位对象
     * @param tableName 表名
     */
    public void savePoint(JSONObject obj, String tableName) {
        //flag:add/up/del
        String flag = obj.getString("flag");
        //处理项目
        Long id = obj.getLong("id");
        if (StringUtil.isNotEmpty(flag)) {
            if (delete.equals(flag)) {
                deleteTableRowByKey(obj, tableName, id, "id", false);
            } else {
                id = saveAndChangeTable(obj, tableName, id, "id", false);
                obj.put("id", id);
            }
        }
    }

    /**
     * 添加或更新项目阶段信息
     *
     * @param obj
     * @param path
     * @param id
     */
    public void saveStageInf(JSONObject obj, String path,String id) {
        //flag:add/up/del
        String flag = obj.getString("flag");
        //处理项目
        Long project_id = obj.getLong("project_id");
        if (StringUtil.isNotEmpty(flag)) {
            if (delete.equals(flag)) {
                deleteTableRowByKey(obj, "p_baseinfo", project_id, "project_id", true);
            } else {
                //如果是新增时候不需要添加此属性
                if (flag.equals("add")) {
                    //obj.put("current_stage", 11);//根据传入值解析
                    obj.put("current_schedule", 12);
                    obj.put("create_time", new Date());
                }
                //语音备注
                String voice_remark = obj.getString("voice_remark");
                if (StringUtil.isNotEmpty(voice_remark)) {
                    //语音移动到指定目录
                    List resultList = new ArrayList();
                    FileUtil.findFiles(path, voice_remark, resultList);
                    //更改语音文件
                    if (resultList.size() > 0) {
                        File file = (File) resultList.get(0);
                        String tempPath = "projectRadio/" + DateUtil.getNowDateStr() + "/";

                        String[] _files = voice_remark.split("\\.");
                        String suffix = _files[1];
                        String filename = _files[0];
                        File fileDir = new File(file_path + tempPath);
                        if (!fileDir.exists()) {
                            fileDir.mkdirs();
                        }
                        FileUtil.fileRomoveTo(file, file_path + tempPath + System.currentTimeMillis() + "." + suffix);
                        obj.put("voice_remark", "upload/" + tempPath + System.currentTimeMillis() + "." + suffix);
                    }
                }
                project_id = saveAndChangeTable(obj, "p_baseinfo", project_id, "project_id",
                        new String[]{"creater", "create_time",  "current_schedule"}, new String[]{}, true);
                obj.put("project_id", project_id);
            }
        }
        //处理阶段
        Long stage_id = obj.getLong("stage_id");
        if (StringUtil.isNotEmpty(flag)) {
            if (delete.equals(flag)) {
                deleteTableRowByKey(obj, "p_stage", stage_id, "stage_id", true);
            } else {
                obj.put("name", obj.get("project_name"));//阶段名称
                obj.put("manager", obj.get("manager_id"));//管理人
                obj.put("explorationer", obj.get("explorationer_id"));//设计者
                obj.put("design_unit", obj.get("design_unit_id"));//国家单位
                obj.put("create_time", new Date());
                //坑货薛 要求新增的时候把上传者的设计单位或者业主单位放入项目中
                Map<String,Object> mapUnit=packageDao.getUnit(id);
                //判断用户是设计单位还是业主单位
                if(mapUnit!=null){
                    int orgType=Integer.parseInt(String.valueOf(mapUnit.get("org_type")));
                    if(orgType==12){//设计单位12
                        obj.put("design_unit", mapUnit.get("org_id"));
                    } else if(orgType==11){//业主单位11
                        obj.put("owner_unit", mapUnit.get("org_id"));
                    }else{//散户不管

                    }
                }

                stage_id = saveAndChangeTable(obj, "p_stage", stage_id, "stage_id", new String[]{"create_time"}, new String[]{}, true);
                obj.put("stage_id", stage_id);
            }
        }
    }

    public void deleteTableRowByKey(JSONObject obj, String tableName, Long id, String keyName, boolean hasDeleted) {
        //查找id 是否存在,存在删除
        Map<String, Object> result1 = packageDao.getObjectByKey(tableName, keyName, id, true);
        if (result1 != null) {
            packageDao.deleteTableRowsByKey(tableName, keyName, id, true);
        } else {
            Map<String, Object> result2 = packageDao.getObjectByUUID(tableName, obj.getString("uuid"), true);
            if (result2 != null) {//查找uuid是否存在,存在删除
                packageDao.deleteTableRowsByKey(tableName, keyName, result2.get(keyName), true);
            } else {
                throw new PackageRuntimeException(SYS.PACK0003.name());
            }
        }
    }

    public Long saveAndChangeTable(JSONObject obj, String tableName, Long id, String keyName, boolean hasDeleted) {
        return saveAndChangeTable(obj, tableName, id, keyName, new String[]{}, new String[]{}, hasDeleted);
    }

    /**
     * 更新数据库
     *
     * @param obj        项目和阶段对象
     * @param tableName  表名
     * @param id         主键值
     * @param keyName    主键名称
     * @param hasDeleted 是否有deleted字段
     * @param arr        排除不更新字段
     * @param arr2       排除不添加字段
     */
    public Long saveAndChangeTable(JSONObject obj, String tableName, Long id, String keyName, String[] arr, String[] arr2, boolean hasDeleted) {
        //查找id 是否存在,存在更新
        Map<String, Object> result1 = packageDao.getObjectByKey(tableName, keyName, id, hasDeleted);
        if (result1 != null) {//更新项目
            packageDao.updateTableByParam(tableName, arr, obj, id);
        } else {
            Map<String, Object> result2 = packageDao.getObjectByUUID(tableName, obj.getString("uuid"), hasDeleted);
            if (result2 != null) {//查找uuid是否存在,存在更新，面对面快传时候
                packageDao.updateTableByParam(tableName, arr, obj, (Long) result2.get(keyName));
                id = Long.parseLong(String.valueOf(result2.get(keyName)));
            } else {// 都不存在,添加,添加
                id = packageDao.insertTableByParam(tableName, arr2, obj);
            }
        }
        return id;
    }
    public Long saveAndChangeTableProblem(JSONObject obj, String tableName, Long id, String keyName, String[] arr, String[] arr2, boolean hasDeleted) {
        //查找id 是否存在,存在更新
        Map<String, Object> result1 = packageDao.getObjectByKey(tableName, keyName, id, hasDeleted);
        if (result1 != null) {//更新项目
            packageDao.updateTableByParam(tableName, arr, obj, id);
        } else {
            Map<String, Object> result2 = packageDao.getObjectByUUID(tableName, obj.getString("uuid"), hasDeleted);
            if (result2 != null) {//查找uuid是否存在,存在更新，面对面快传时候
                packageDao.updateTableByParam(tableName, arr, obj, (Long) result2.get(keyName));
                id = Long.parseLong(String.valueOf(result2.get(keyName)));
            } else {// 都不存在,添加,添加
                id = packageDao.insertTableByParam(tableName, arr2, obj);
            }
        }
        return id;
    }

    /**
     * 解析文件到JSONObject
     *
     * @param baseDIR  压缩包根目录路径
     * @param fileName 查找文件
     */
    public JSONObject parseFileToJSONObject(String baseDIR, String fileName) {
        List resultList = new ArrayList();
        FileUtil.findFiles(baseDIR, fileName, resultList);
        if (resultList.size() == 0) {
//            throw new PackageRuntimeException(SYS.PACK0001.name());
            return null;
        } else if (resultList.size() > 1) {
            throw new PackageRuntimeException(SYS.PACK0002.name());
        } else {//项目阶段文件只有一个
            JSONObject obj = JSONObject.parseObject(FileUtil.readFile((File) resultList.get(0)));
            return obj;
        }
    }

    /**
     * 解析文件到JSONArray
     *
     * @param baseDIR  压缩包根目录路径
     * @param fileName 查找文件
     */
    public JSONArray parseFileToJSONArray(String baseDIR, String fileName) {
        List resultList = new ArrayList();
        FileUtil.findFiles(baseDIR, fileName, resultList);
        if (resultList.size() == 0) {
//            throw new PackageRuntimeException(SYS.PACK0001.name());
            return null;
        } else {//项目阶段文件只有一个
            JSONArray jsonArray = new JSONArray();
            for (int i = 0; i < resultList.size(); i++) {
                JSONObject obj = JSONObject.parseObject(FileUtil.readFile((File) resultList.get(i)));
                jsonArray.add(obj);
            }
            return jsonArray;
        }
    }

    public static boolean isLong(String value) {
        try {
            Long.parseLong(value);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

    /**********************************解包结束**************************************************/

//    public static void  main(String[] args){
//        new PackageServiceImpl().analysisPackage("F:\\ProjectStage_e7f64a1d-681e-4a6f-94c5-47af9a02028e","e7f64a1d-681e-4a6f-94c5-47af9a02028e");
//    }
}
